import IMCore  from "./IMCore";
const ws_protocol = 'ws'; // ws 或 wss
const ip = '127.0.0.1'
const port = 9326

const heartbeatTimeout = 30000; // 心跳超时时间，单位：毫秒
const reconnInterval = 1000; // 重连间隔时间，单位：毫秒

const binaryType = 'blob'; // 'blob' or 'arraybuffer';//arraybuffer是字节

/**
 * 生成从minNum到maxNum的随机数
 * @param {*} minNum 
 * @param {*} maxNum 
 */
const randomNum=(minNum,maxNum)=>{
    switch(arguments.length){ 
        case 1: 
            return parseInt(Math.random()*minNum+1,10); 
        break; 
        case 2: 
            return parseInt(Math.random()*(maxNum-minNum+1)+minNum,10); 
        break; 
            default: 
                return 0; 
            break; 
    } 
}
export default {
    ws:null,
    initWs:function(token,handler){
        var params="";
        if(token){
            params="token="+token
        }
        IMCore.init(ws_protocol, ip, port, params, handler, heartbeatTimeout, reconnInterval, binaryType);
        this.ws=IMCore.connect("");
    }
}





